package bulk_param.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import bulk_param.modele.JTextFieldLimit;
import bulk_param.modele.ReadCVS;
import bulk_param.numspe.controller.ButtonNumSpeInactiveController;
import bulk_param.numspe.controller.ColorErrorNumSpeInactivationController;
import bulk_param.numspe.controller.TextZABPQInactiveListener;

import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JTextFieldDateEditor;

public class NumSpe_Inactive_View extends JPanel{	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Font font = new Font("Comic Sans MS", Font.BOLD, 12);
	private Font fontBouton = new Font("Broadway", Font.BOLD, 12);
	private JPanel panelInactivePoint;
	private JPanel inactivation_Panel;
	public JDateChooser dateChooser;
	public JTextFieldDateEditor dateEditor;
	public JButton btInactiver ;
	private String selectDate = "Séléction de Date";
	public JRadioButton national, international;
	public JLabel lbVide,lbVide2,lbPays, lbZABPQ, lbInactiveDt;
	public JComboBox<String> cbPays;
	public JTextField txtZABPQ;
	private ReadCVS readCVS;
	//Liste des contenus combobox
	public ArrayList<String> listPaysFixeMobile;
	
	public NumSpe_Inactive_View(){
		
	}
	
	public JPanel panelInactiveNumSepciaux(){						
		
		
		//Remplissage combobox Pays
		readCVS = new ReadCVS();
		listPaysFixeMobile=readCVS.countryDictionary();
		
		//Panel Open_Point
		panelInactivePoint = new JPanel();
		panelInactivePoint.setLayout(new BorderLayout());		
		
		
		//GridBagLayout pour les champs d'activation du point ZABPQ
        inactivation_Panel = new JPanel();
        inactivation_Panel.setLayout(new GridBagLayout());
        		
        
        GridBagConstraints gridBagConstraintsPointZABPQ = new GridBagConstraints();
        lbZABPQ = new JLabel("Point(03BPQ) : ");
        gridBagConstraintsPointZABPQ.gridx = 0;
        gridBagConstraintsPointZABPQ.gridy = 1;
        gridBagConstraintsPointZABPQ.insets = new Insets(20, 100, 20, 5);
        gridBagConstraintsPointZABPQ.anchor = gridBagConstraintsPointZABPQ.WEST;
        inactivation_Panel.add(lbZABPQ, gridBagConstraintsPointZABPQ);
        
        GridBagConstraints gridBagConstraintsPoint = new GridBagConstraints();
        txtZABPQ = new JTextField(12);
        txtZABPQ.setDocument(new JTextFieldLimit(7));
        gridBagConstraintsPoint.gridx = 1;
        gridBagConstraintsPoint.gridy = 1;
        gridBagConstraintsPoint.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsPoint.anchor = gridBagConstraintsPoint.WEST;
        inactivation_Panel.add(txtZABPQ, gridBagConstraintsPoint);                     
        
     // libelle deuxieme ligne
        GridBagConstraints gridBagConstraintsInactiveDt = new GridBagConstraints();
        lbInactiveDt = new JLabel("Date d'inactivation : ");
        gridBagConstraintsInactiveDt.gridx = 0;
        gridBagConstraintsInactiveDt.gridy = 2;
        gridBagConstraintsInactiveDt.insets = new Insets(20, 100, 20, 5);
        gridBagConstraintsInactiveDt.anchor = gridBagConstraintsInactiveDt.WEST;
        inactivation_Panel.add(lbInactiveDt, gridBagConstraintsInactiveDt);
        
        GridBagConstraints gridBagConstraintsTxtInactiveDt = new GridBagConstraints();    
        dateChooser = new JDateChooser();
        dateChooser.setDateFormatString("dd/MM/yyyy");
        dateChooser.setPreferredSize(new Dimension(135, 21));
        dateEditor = (JTextFieldDateEditor)dateChooser.getDateEditor();
        dateEditor.setEditable(false);
        dateEditor.setText(selectDate);
        dateEditor.setForeground(Color.gray);
        gridBagConstraintsTxtInactiveDt.gridx = 1;
        gridBagConstraintsTxtInactiveDt.gridy = 2;
        gridBagConstraintsTxtInactiveDt.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsTxtInactiveDt.anchor = gridBagConstraintsTxtInactiveDt.WEST;
        inactivation_Panel.add(dateChooser, gridBagConstraintsTxtInactiveDt);

 
        //lieblle boutton
        GridBagConstraints gridBagConstraintsbtValider = new GridBagConstraints();
        btInactiver = new JButton("Inactiver");
        btInactiver.setPreferredSize(new Dimension(135,21));
        btInactiver.setBackground(Color.black);
        btInactiver.setFont(fontBouton);
        btInactiver.setForeground(Color.getHSBColor(39,233,255));
        gridBagConstraintsbtValider.gridx = 1;
        gridBagConstraintsbtValider.gridy = 3;
        gridBagConstraintsbtValider.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsbtValider.anchor = gridBagConstraintsbtValider.WEST;
        inactivation_Panel.add(btInactiver, gridBagConstraintsbtValider); 
        
      //Type de trafic
  		JPanel panelTrafic= new JPanel();
  		Border titledBorderTrafic = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.getHSBColor(93/360F, 0.57F, 0.60F)), "Numéros Spéciaux :", TitledBorder.LEFT, TitledBorder.TOP, font, Color.getHSBColor(93/255F, 0.57F, 0.60F));
  		panelTrafic.setBorder(BorderFactory.createTitledBorder(titledBorderTrafic));  		
  		panelTrafic.add(inactivation_Panel);                  
		  
		//ZABPQ OPEN_CONTACT LAYOUT        
		panelInactivePoint.add(panelTrafic,BorderLayout.CENTER);
		
		txtZABPQ.addMouseListener(new ColorErrorNumSpeInactivationController(this));
		dateEditor.addMouseListener(new ColorErrorNumSpeInactivationController(this));
		btInactiver.addActionListener(new ButtonNumSpeInactiveController(this));
		txtZABPQ.addKeyListener(new TextZABPQInactiveListener(this));
		
		return panelInactivePoint;
						
	}		
}
